# /syringe/exploits/pwnage2/Makefile
XXD = xxd
CROSS := arm-elf-
ARMCC = $(CROSS)gcc
ARMOBJCOPY = $(CROSS)objcopy

CFLAGS := -I../../../include

EXPLOIT_NAME = pwnage2
EXPLOIT_TARGET = $(EXPLOIT_NAME).o
EXPLOIT_SOURCE = $(EXPLOIT_NAME).c

PAYLOAD_NAME = $(EXPLOIT_NAME)
PAYLOAD_TARGET = $(PAYLOAD_NAME).h
PAYLOAD_SOURCE = $(PAYLOAD_NAME).S

TARGETS = $(EXPLOIT_TARGET) $(PAYLOAD_TARGET)

$(EXPLOIT_TARGET): $(PAYLOAD_TARGET)
	$(CC) -o $(EXPLOIT_TARGET) -c $(EXPLOIT_SOURCE) $(CFLAGS)
	
$(PAYLOAD_TARGET):
	$(ARMCC) -o $(PAYLOAD_NAME).o -c $(PAYLOAD_SOURCE) $(ARMCFLAGS) $(ARMLDFLAGS)
	$(ARMOBJCOPY) -O binary $(PAYLOAD_NAME).o $(PAYLOAD_NAME)
	$(XXD) -i $(PAYLOAD_NAME) $(PAYLOAD_TARGET)

all: $(TARGETS)

clean:
	$(RM) $(EXPLOIT_NAME) *.o *.bin
